package cn.com.code.generator.service.impl;

import cn.com.code.generator.dao.TaskStatusDao;
import cn.com.code.generator.entity.TaskStatus;
import cn.com.code.generator.service.TaskStatusService;
import cn.com.do1.dsf.compont.mysql.utils.PageUtils;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("taskStatusService")
public class TaskStatusServiceImpl extends ServiceImpl<TaskStatusDao, TaskStatus> implements TaskStatusService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        return null;
    }

    @Override
    public List<TaskStatus> queryAll(Map<String, Object> params) {
        return this.selectList(getEntityWrapper(params));
    }

    private Wrapper<TaskStatus> getEntityWrapper(Map<String, Object> params){
                                                        		String taskDefinitionKey = (String)params.get("taskDefinitionKey");
                                                		Boolean status = (Boolean)params.get("status");
                
        return new EntityWrapper<TaskStatus>()
                                                        				.like(StringUtils.isNotEmpty(taskDefinitionKey),"task_definition_key", taskDefinitionKey)
                                                				.eq(status != null,"status", status)
                        ;
    }

}
